/**  
 * All rights Reserved, Designed By www.woniuxy.com
 * @Title:  Account.java   
 * @Package com.woniu.domain   
 * @Description:    Description  
 * @author: 蜗牛学院  
 * @date:   2019年8月22日 下午4:32:59
 * @user:   Administrator  
 * @version V1.0 
 * @Copyright: 2019 www.woniuxy.com Inc. All rights reserved. 
 * 注意：本内容仅限于成都蜗牛创想科技有限公司，禁止外泄以及用于其他的商业目
 */ 
package com.woniu.ssh.controller;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.woniu.ssh.domain.Manager;
import com.woniu.ssh.service.UserService;

/**
 * @author Administrator
 *
 */
@Controller
@Scope("prototype")
public class UserAction {
	@Autowired
	UserService userService;
	Manager manager;
	public String login() {
		try {
			Manager m = userService.fingUserByUserName(manager.getUname());
			if(m==null) {
				ActionContext.getContext().put("usererrorinfo", "用户名不存在");
				return "error";
			}else if(m.getUpwd().equals(manager.getUpwd())) {
				ActionContext.getContext().getSession().put("userinfo", m);
				return "login";
			}else {
				ActionContext.getContext().put("usererrorinfo", "密码错误");
				return "error";
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return "";
	}
	/**
	 * @return the manager
	 */
	public Manager getManager() {
		return manager;
	}
	/**
	 * @param manager the manager to set
	 */
	public void setManager(Manager manager) {
		this.manager = manager;
	}
	
}
